package com.buer.train.common.utils;

public class SexUtil {
    public static String userType(String idNumber) {
        String userType = "";
        int gender = 0;
        if(idNumber.length() == 18){
            //如果身份证号18位，取身份证号倒数第二位
            char c = idNumber.charAt(idNumber.length() - 2);
            gender = Integer.parseInt(String.valueOf(c));
        }else{
            //如果身份证号15位，取身份证号最后一位
            char c = idNumber.charAt(idNumber.length() - 1);
            gender = Integer.parseInt(String.valueOf(c));
        }
        System.out.println("gender = " + gender);
        if(gender % 2 == 1){
            userType =  "男";
        }else{
            userType =  "女";
        }
        return userType;
    }
}
